/*
 *   Copyright 2022 RenFei(i@renfei.net)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package net.renfei.common.api.constant.enums;

/**
 * 常见文件后缀名和 Content-type/ mimetype对应关系
 *
 * @author renfei
 */
public enum ContentTypeEnum {
    DESSERT(".*", "application/octet-stream"),
    _001(".001", "application/x-001"),
    _301(".301", "application/x-301"),
    _323(".323", "text/h323"),
    _906(".906", "application/x-906"),
    _907(".907", "drawing/907"),
    _a11(".a11", "application/x-a11"),
    _acp(".acp", "audio/x-mei-aac"),
    _ai(".ai", "application/postscript"),
    _aif(".aif", "audio/aiff"),
    _aifc(".aifc", "audio/aiff"),
    _aiff(".aiff", "audio/aiff"),
    _anv(".anv", "application/x-anv"),
    _asa(".asa", "text/asa"),
    _asf(".asf", "video/x-ms-asf"),
    _asp(".asp", "text/asp"),
    _asx(".asx", "video/x-ms-asf"),
    _au(".au", "audio/basic"),
    _avi(".avi", "video/avi"),
    _awf(".awf", "application/vnd.adobe.workflow"),
    _biz(".biz", "text/xml"),
    _bmp(".bmp", "application/x-bmp"),
    _bot(".bot", "application/x-bot"),
    _c4t(".c4t", "application/x-c4t"),
    _c90(".c90", "application/x-c90"),
    _cal(".cal", "application/x-cals"),
    _cat(".cat", "application/vnd.ms-pki.seccat"),
    _cdf(".cdf", "application/x-netcdf"),
    _cdr(".cdr", "application/x-cdr"),
    _cel(".cel", "application/x-cel"),
    _cer(".cer", "application/x-x509-ca-cert"),
    _cg4(".cg4", "application/x-g4"),
    _cgm(".cgm", "application/x-cgm"),
    _cit(".cit", "application/x-cit"),
    _class(".class", "java/*"),
    _cml(".cml", "text/xml"),
    _cmp(".cmp", "application/x-cmp"),
    _cmx(".cmx", "application/x-cmx"),
    _cot(".cot", "application/x-cot"),
    _crl(".crl", "application/pkix-crl"),
    _crt(".crt", "application/x-x509-ca-cert"),
    _csi(".csi", "application/x-csi"),
    _css(".css", "text/css"),
    _cut(".cut", "application/x-cut"),
    _dbf(".dbf", "application/x-dbf"),
    _dbm(".dbm", "application/x-dbm"),
    _dbx(".dbx", "application/x-dbx"),
    _dcd(".dcd", "text/xml"),
    _dcx(".dcx", "application/x-dcx"),
    _der(".der", "application/x-x509-ca-cert"),
    _dgn(".dgn", "application/x-dgn"),
    _dib(".dib", "application/x-dib"),
    _dll(".dll", "application/x-msdownload"),
    _doc(".doc", "application/msword"),
    _dot(".dot", "application/msword"),
    _drw(".drw", "application/x-drw"),
    _dtd(".dtd", "text/xml"),
    _dwf(".dwf", "application/x-dwf"),
    _dwg(".dwg", "application/x-dwg"),
    _dxb(".dxb", "application/x-dxb"),
    _dxf(".dxf", "application/x-dxf"),
    edn(".edn", "application/vnd.adobe.edn"),
    emf(".emf", "application/x-emf"),
    eml(".eml", "message/rfc822"),
    ent(".ent", "text/xml"),
    epi(".epi", "application/x-epi"),
    eps(".eps", "application/x-ps"),
    etd(".etd", "application/x-ebx"),
    exe(".exe", "application/x-msdownload"),
    fax(".fax", "image/fax"),
    fdf(".fdf", "application/vnd.fdf"),
    fif(".fif", "application/fractals"),
    fo(".fo", "text/xml"),
    frm(".frm", "application/x-frm"),
    g4(".g4", "application/x-g4"),
    gbr(".gbr", "application/x-gbr"),
    gcd(".gcd", "application/x-gcd"),
    gif(".gif", "image/gif"),
    gl2(".gl2", "application/x-gl2"),
    gp4(".gp4", "application/x-gp4"),
    hgl(".hgl", "application/x-hgl"),
    hmr(".hmr", "application/x-hmr"),
    hpg(".hpg", "application/x-hpgl"),
    hpl(".hpl", "application/x-hpl"),
    hqx(".hqx", "application/mac-binhex40"),
    hrf(".hrf", "application/x-hrf"),
    hta(".hta", "application/hta"),
    htc(".htc", "text/x-component"),
    htm(".htm", "text/html"),
    html(".html", "text/html"),
    htt(".htt", "text/webviewhtml"),
    htx(".htx", "text/html"),
    icb(".icb", "application/x-icb"),
    ico(".ico", "application/x-ico"),
    iff(".iff", "application/x-iff"),
    ig4(".ig4", "application/x-g4"),
    igs(".igs", "application/x-igs"),
    iii(".iii", "application/x-iphone"),
    img(".img", "application/x-img"),
    ins(".ins", "application/x-internet-signup"),
    isp(".isp", "application/x-internet-signup"),
    IVF(".IVF", "video/x-ivf"),
    java(".java", "java/*"),
    jfif(".jfif", "image/jpeg"),
    jpe(".jpe", "image/jpeg"),
    jpeg(".jpeg", "image/jpeg"),
    jpg(".jpg", "image/jpeg"),
    js(".js", "application/x-javascript"),
    jsp(".jsp", "text/html"),
    la1(".la1", "audio/x-liquid-file"),
    lar(".lar", "application/x-laplayer-reg"),
    latex(".latex", "application/x-latex"),
    lavs(".lavs", "audio/x-liquid-secure"),
    lbm(".lbm", "application/x-lbm"),
    lmsff(".lmsff", "audio/x-la-lms"),
    ls(".ls", "application/x-javascript"),
    ltr(".ltr", "application/x-ltr"),
    m1v(".m1v", "video/x-mpeg"),
    m2v(".m2v", "video/x-mpeg"),
    m3u(".m3u", "audio/mpegurl"),
    m4e(".m4e", "video/mpeg4"),
    mac(".mac", "application/x-mac"),
    man(".man", "application/x-troff-man"),
    mat(".math", "text/xml"),
    mdb(".mdb", "application/msaccess"),
    mfp(".mfp", "application/x-shockwave-flash"),
    mht(".mht", "message/rfc822"),
    mhtml(".mhtml", "message/rfc822"),
    mi(".mi", "application/x-mi"),
    mid(".mid", "audio/mid"),
    midi(".midi", "audio/mid"),
    mil(".mil", "application/x-mil"),
    mml(".mml", "text/xml"),
    mnd(".mnd", "audio/x-musicnet-download"),
    mns(".mns", "audio/x-musicnet-stream"),
    mocha(".mocha", "application/x-javascript"),
    movie(".movie", "video/x-sgi-movie"),
    mp1(".mp1", "audio/mp1"),
    mp2(".mp2", "audio/mp2"),
    mp2v(".mp2v", "video/mpeg"),
    mp3(".mp3", "audio/mp3"),
    mp4(".mp4", "video/mpeg4"),
    mpa(".mpa", "video/x-mpg"),
    mpd(".mpd", "application/vnd.ms-project"),
    mpe(".mpe", "video/x-mpeg"),
    mpeg(".mpeg", "video/mpg"),
    mpg(".mpg", "video/mpg"),
    mpga(".mpga", "audio/rn-mpeg"),
    mpp(".mpp", "application/vnd.ms-project"),
    mps(".mps", "video/x-mpeg"),
    mpt(".mpt", "application/vnd.ms-project"),
    mpv(".mpv", "video/mpg"),
    mpv2(".mpv2", "video/mpeg"),
    mpw(".mpw", "application/vnd.ms-project"),
    mpx(".mpx", "application/vnd.ms-project"),
    mtx(".mtx", "text/xml"),
    mxp(".mxp", "application/x-mmxp"),
    net(".net", "image/pnetvue"),
    nrf(".nrf", "application/x-nrf"),
    nws(".nws", "message/rfc822"),
    odc(".odc", "text/x-ms-odc"),
    out(".out", "application/x-out"),
    p10(".p10", "application/pkcs10"),
    p12(".p12", "application/x-pkcs12"),
    p7b(".p7b", "application/x-pkcs7-certificates"),
    p7c(".p7c", "application/pkcs7-mime"),
    p7m(".p7m", "application/pkcs7-mime"),
    p7r(".p7r", "application/x-pkcs7-certreqresp"),
    p7s(".p7s", "application/pkcs7-signature"),
    pc5(".pc5", "application/x-pc5"),
    pci(".pci", "application/x-pci"),
    pcl(".pcl", "application/x-pcl"),
    pcx(".pcx", "application/x-pcx"),
    pdf(".pdf", "application/pdf"),
    pdx(".pdx", "application/vnd.adobe.pdx"),
    pfx(".pfx", "application/x-pkcs12"),
    pgl(".pgl", "application/x-pgl"),
    pic(".pic", "application/x-pic"),
    pko(".pko", "application/vnd.ms-pki.pko"),
    pl(".pl", "application/x-perl"),
    plg(".plg", "text/html"),
    pls(".pls", "audio/scpls"),
    plt(".plt", "application/x-plt"),
    png(".png", "image/png"),
    pot(".pot", "application/vnd.ms-powerpoint"),
    ppa(".ppa", "application/vnd.ms-powerpoint"),
    ppm(".ppm", "application/x-ppm"),
    pps(".pps", "application/vnd.ms-powerpoint"),
    ppt(".ppt", "application/x-ppt"),
    pr(".pr", "application/x-pr"),
    prf(".prf", "application/pics-rules"),
    prn(".prn", "application/x-prn"),
    prt(".prt", "application/x-prt"),
    ps(".ps", "application/x-ps"),
    ptn(".ptn", "application/x-ptn"),
    pwz(".pwz", "application/vnd.ms-powerpoint"),
    r3t(".r3t", "text/vnd.rn-realtext3d"),
    ra(".ra", "audio/vnd.rn-realaudio"),
    ram(".ram", "audio/x-pn-realaudio"),
    ras(".ras", "application/x-ras"),
    rat(".rat", "application/rat-file"),
    rdf(".rdf", "text/xml"),
    rec(".rec", "application/vnd.rn-recording"),
    red(".red", "application/x-red"),
    rgb(".rgb", "application/x-rgb"),
    rjs(".rjs", "application/vnd.rn-realsystem-rjs"),
    rjt(".rjt", "application/vnd.rn-realsystem-rjt"),
    rlc(".rlc", "application/x-rlc"),
    rle(".rle", "application/x-rle"),
    rm(".rm", "application/vnd.rn-realmedia"),
    rmf(".rmf", "application/vnd.adobe.rmf"),
    rmi(".rmi", "audio/mid"),
    rmj(".rmj", "application/vnd.rn-realsystem-rmj"),
    rmm(".rmm", "audio/x-pn-realaudio"),
    rmp(".rmp", "application/vnd.rn-rn_music_package"),
    rms(".rms", "application/vnd.rn-realmedia-secure"),
    rmv(".rmvb", "application/vnd.rn-realmedia-vbr"),
    rmx(".rmx", "application/vnd.rn-realsystem-rmx"),
    rnx(".rnx", "application/vnd.rn-realplayer"),
    rp(".rp", "image/vnd.rn-realpix"),
    rpm(".rpm", "audio/x-pn-realaudio-plugin"),
    rsm(".rsml", "application/vnd.rn-rsml"),
    rt(".rt", "text/vnd.rn-realtext"),
    rtf(".rtf", "application/msword"),
    xrtf(".rtf", "application/x-rtf"),
    rv(".rv", "video/vnd.rn-realvideo"),
    sam(".sam", "application/x-sam"),
    sat(".sat", "application/x-sat"),
    sdp(".sdp", "application/sdp"),
    sdw(".sdw", "application/x-sdw"),
    sit(".sit", "application/x-stuffit"),
    slb(".slb", "application/x-slb"),
    sld(".sld", "application/x-sld"),
    slk(".slk", "drawing/x-slk"),
    smi(".smi", "application/smil"),
    smil(".smil", "application/smil"),
    smk(".smk", "application/x-smk"),
    snd(".snd", "audio/basic"),
    sol(".sol", "text/plain"),
    sor(".sor", "text/plain"),
    spc(".spc", "application/x-pkcs7-certificates"),
    spl(".spl", "application/futuresplash"),
    spp(".spp", "text/xml"),
    vml(".vml", "text/xml"),
    vpg(".vpg", "application/x-vpeg005"),
    vsd(".vsd", "application/vnd.visio"),
    xvsd(".vsd", "application/x-vsd"),
    vss(".vss", "application/vnd.visio"),
    vst(".vst", "application/vnd.visio"),
    xvst(".vst", "application/x-vst"),
    vsw(".vsw", "application/vnd.visio"),
    vsx(".vsx", "application/vnd.visio"),
    vtx(".vtx", "application/vnd.visio"),
    vxml(".vxml", "text/xml"),
    wav(".wav", "audio/wav"),
    wax(".wax", "audio/x-ms-wax"),
    wb1(".wb1", "application/x-wb1"),
    wb2(".wb2", "application/x-wb2"),
    wb3(".wb3", "application/x-wb3"),
    wbmp(".wbmp", "image/vnd.wap.wbmp"),
    wiz(".wiz", "application/msword"),
    wk3(".wk3", "application/x-wk3"),
    wk4(".wk4", "application/x-wk4"),
    wkq(".wkq", "application/x-wkq"),
    wks(".wks", "application/x-wks"),
    wm(".wm", "video/x-ms-wm"),
    wma(".wma", "audio/x-ms-wma"),
    wmd(".wmd", "application/x-ms-wmd"),
    wmf(".wmf", "application/x-wmf"),
    wml(".wml", "text/vnd.wap.wml"),
    wmv(".wmv", "video/x-ms-wmv"),
    wmx(".wmx", "video/x-ms-wmx"),
    wmz(".wmz", "application/x-ms-wmz"),
    wp6(".wp6", "application/x-wp6"),
    wpd(".wpd", "application/x-wpd"),
    wpg(".wpg", "application/x-wpg"),
    wpl(".wpl", "application/vnd.ms-wpl"),
    wq1(".wq1", "application/x-wq1"),
    wr1(".wr1", "application/x-wr1"),
    wri(".wri", "application/x-wri"),
    wrk(".wrk", "application/x-wrk"),
    ws(".ws", "application/x-ws"),
    ws2(".ws2", "application/x-ws"),
    wsc(".wsc", "text/scriptlet"),
    wsd(".wsdl", "text/xml"),
    wvx(".wvx", "video/x-ms-wvx"),
    xdp(".xdp", "application/vnd.adobe.xdp"),
    xdr(".xdr", "text/xml"),
    xfd(".xfd", "application/vnd.adobe.xfd"),
    xfdf(".xfdf", "application/vnd.adobe.xfdf"),
    xhtml(".xhtml", "text/html"),
    xls(".xls", "application/x-xls"),
    xlw(".xlw", "application/x-xlw"),
    xml(".xml", "text/xml"),
    xpl(".xpl", "audio/scpls"),
    xq(".xq", "text/xml"),
    xql(".xql", "text/xml"),
    xquery(".xquery", "text/xml"),
    xsd(".xsd", "text/xml"),
    xsl(".xsl", "text/xml"),
    xslt(".xslt", "text/xml"),
    xwd(".xwd", "application/x-xwd"),
    x_b(".x_b", "application/x-x_b"),
    x_t(".x_t", "application/x-x_t");

    private final String code;

    private final String desc;

    ContentTypeEnum(final String code, final String desc) {
        this.code = code;
        this.desc = desc;
    }

    public static String getCode(String value) {
        ContentTypeEnum[] contentTypeEnums = values();
        for (ContentTypeEnum contentTypeEnum : contentTypeEnums) {
            if (contentTypeEnum.code().equals(value)) {
                return contentTypeEnum.code();
            }
        }
        return null;
    }

    public static String getDesc(String value) {
        ContentTypeEnum[] contentTypeEnums = values();
        for (ContentTypeEnum contentTypeEnum : contentTypeEnums) {
            if (contentTypeEnum.code().equals(value)) {
                return contentTypeEnum.desc();
            }
        }
        return "multipart/form-data";
    }



    public String code() {
        return this.code;
    }

    public String desc() {
        return this.desc;
    }
}
